package com.morgankelly.dao;

import javax.jdo.PersistenceManager;

import com.morgankelly.po.Category;
import com.morgankelly.util.PMF;

public class CategoryDAO extends GenericDAO<Category> {
	
	private static CategoryDAO instance = null;

	private CategoryDAO() {}

	public static synchronized CategoryDAO get() {
		if (instance == null) {instance = new CategoryDAO();}
		return instance;
	}
	
	public void update(Long id, String name, String description) {
		PersistenceManager pm = PMF.get().getPersistenceManager();
		 Category entry = pm.getObjectById(Category.class, id);
		 //Category detached = pm.detachCopy(entry);

		 
		 entry.setName(name);
		 entry.setDescription(description);
		 
		 pm.makePersistent(entry);
		 
		 Category entry2 = pm.getObjectById(Category.class, id);
		 
		 System.out.println(entry2.getName());
		 System.out.println(entry2.getDescription());

	}
}
